--- libvmime-0.7.1.orig/vmime/utility/smartPtr.hpp	2005-05-19 19:17:17.000000000 +0200
+++ libvmime-0.7.1.patched/vmime/utility/smartPtr.hpp	2009-05-13 15:21:53.276875219 +0200
@@ -20,6 +20,9 @@
 #ifndef VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
 #define VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
 
+// non-portable, but atleast not an abi change
+#include <pthread.h>
+static pthread_mutex_t mapLock = PTHREAD_MUTEX_INITIALIZER;
 
 namespace vmime {
 namespace utility {
@@ -108,8 +111,10 @@
 		{
 			if (m_data->refCount == 1)
 			{
+				pthread_mutex_lock(&mapLock);
 				typename MapType::iterator it = sm_map.find(m_data->ptr);
 				if (it != sm_map.end()) sm_map.erase(it);
+				pthread_mutex_unlock(&mapLock);
 
 				delete (m_data->ptr);
 				delete (m_data);
@@ -127,6 +132,8 @@
 	{
 		detach();
 
+		pthread_mutex_lock(&mapLock);
+
 		typename MapType::iterator it = sm_map.find(p);
 
 		if (it != sm_map.end())
@@ -141,6 +148,7 @@
 
 			sm_map.insert(typename MapType::value_type(p, m_data));
 		}
+		pthread_mutex_unlock(&mapLock);
 	}
 
 	void attach(const smart_ptr <T>& p)
